Pointers are variables which refer to
the memory locations of other variables.
So how about an analogy for
this. Let's take a few houses. Each house is a memory address, the value in
the house is the person that lives there. Note that people will move, but the
houses always stay there. It might look something like it shown in example
above. Think of "647" as the person that lives at address
"0x5FA70".
x
could be the car that gets you to see that nice person, "647". If
you put an ampersand(
&)
in front of
x
you are looking for the house address and you could care less about who's
inside.
A memory address is a location within your computers memory. Its where
something is. And each one of your variables has a memory address of its own.
Which means that at that address in memory is the value of that variable. Say
for instance you have a single integer named
x and it has a value of
654. Let's pretend that
x's memory address is "0x5FA70" (hexidecimal).
At the location "0x5FA70" in computers memory is the number
654. At the memory
address "0x5FA70" is the number
654. "..." in the other boxes means that we
don't know what's at those memory locations.
The memory addresses are
defined in hexidecimal because its easier to represent them that way. Also,
the addresses in this depiction increase in increments of 4. That is because
the size (in bytes) of an integer is usually four (unless you're working with
a crummy ol' 16-bit compiler).